import java.util.ArrayList;

class PrimeNumbers {
	public static void main(String[] args) {
		UserInput input = new UserInput();
		int number = input.getNumber("Please enter number:");
        Integer[] primeNumbers = getPrimeNumbers(number);
        printResult(primeNumbers);
	}

    private static void printResult(Integer[] primeNumbers) {
        for(int i = 0; i < primeNumbers.length; i = i + 1) {
            System.out.println(primeNumbers[i]);
        }
    }

    private static Integer[] getPrimeNumbers(int number) {
        ArrayList<Integer> primeNumbers = new ArrayList<Integer>();
        Integer[] result;
        boolean isPrime;
        for (int i = 1; i <= number; i = i + 1) {
            isPrime = true;
            for (int j = 2; j < i; j = j + 1) {
                if (i % j == 0) {
                    isPrime = false;
                    break;
                }
            }
            if (isPrime) {
                primeNumbers.add(i);
            }
        }
        result = new Integer[primeNumbers.size()];
        primeNumbers.toArray(result);
        return result;
    }
}